package com.learning.spring.cloud.ms.consumer.movie.controller;

import com.learning.spring.cloud.ms.consumer.movie.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * ClassName: MovieController
 * Description:
 * Date: 2019/5/31 10:42 【需求编号】
 *
 * @author Sam Sho
 * @version V1.0.0
 */
@RestController
@RequestMapping("movie")
public class MovieController {

    @Autowired
    private RestTemplate restTemplate;

    /**
     * http://localhost:8010/movie/user/1
     *
     * @param id
     * @return
     */
    @GetMapping("/user/{id}")
    public User findById(@PathVariable Long id) {

        // 访问用户服务
        return this.restTemplate.getForObject("http://localhost:8000/user/" + id, User.class);
    }
}
